﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Yang.DataBase;

public partial class getColumnName : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        Response.Charset = "utf-8";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");

        string ProductType = "";                //成果类型
        //int language = 0; //语言类型（中文1、英文2、全部0）

        ProductType = Request.QueryString[0].ToString();
        ProductType = Utility.ProductId2Name(ProductType);//得到成果类型的中文名称，也就是数据库中的表名称



        string queryString = " select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='" + ProductType + "') order by colid";

        string resultXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\n";
        resultXml += "<ResultList>" + "\n";

        DataSet ds = Database.Query(queryString);

        DataTable dt = ds.Tables[0];

        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                resultXml += "<Result ";
                resultXml += "ColumnName" + i + " = '" + dt.Rows[i][0].ToString().Trim() + "' ";
                resultXml += " />" + "\n";
            }
        }

        resultXml += "</ResultList>";

        Response.Write(resultXml);

    }
}
